<?php

namespace LowCode\UI;

use LowCode\Support\JsExp;
use LowCode\Traits\HasDeprecatedChildren;

/**
 *
 * 代码 Code
 * @method static static make(string|JsExp $code = null) Code组件
 */
class Code extends Node
{
    use HasDeprecatedChildren;
    public function __construct(string|JsExp $code = null)
    {
        parent::__construct("WCode");
        $this->code($code);
        $this->language("php");
    }

    /**
     * 使用行内样式
     * @param bool|JsExp $bool
     * @return $this
     */
    public function inline(bool|JsExp $bool = true): Code
    {
        return $this->prop('inline', $bool);
    }

    /**
     * 代码内容
     * @param string|JsExp $code
     * @return $this
     */
    public function code(string|JsExp $code): Code
    {
        return $this->prop('code', $code);
    }

    /**
     * 代码语言
     *  bash,c,cpp,csharp,css,diff,go,graphql,ini,java,javascript,json,kotlin,less,lua,makefile,
     *  markdown,objectivec,perl,php,php_template,plaintext,python,python_repl,r,ruby,rust,
     *  scss,_shell,sql,swift,typescript,vbnet,wasm,xml,yaml
     * @param string|JsExp $language
     * @return $this
     */
    public function language(string|JsExp $language = "php"|"go"|"python"|"javascript"|"javascript"|"json"|"java"|"css"|"less"|"scss"|"xml"|"sql"): Code
    {
        return $this->prop('language', $language);
    }


    /**
     * 是否显示行号，在 inline 或 word-wrap 的情况下不生效
     * @param bool|JsExp $bool
     * @return $this
     */
    public function showLineNumbers(bool|JsExp $bool = true): Code
    {
        return $this->prop('show-line-numbers', $bool);
    }

    /**
     * 是否显示 trim 后的代码
     * @param bool|JsExp $bool
     * @return $this
     */
    public function trim(bool|JsExp $bool = true): Code
    {
        return $this->prop('trim', $bool);
    }

    /**
     * 代码过长时是否自动换行
     * @param string|bool $bool
     * @return $this
     */
    public function wordWrap(string|bool $bool = true): Code
    {
        return $this->prop('word-wrap', $bool);
    }

    /**
     * @param bool|JsExp $bool
     * @return $this
     */
    public function dark(bool|JsExp $bool = true): Code
    {
        return $this->prop('dark', $bool);
    }


}
